using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;

using Common;

using GRPCDemo.DataBase;

namespace GRPCDemo.Services
{
    public class DBService : Singleton<DBService>
    {
        EntitiesContext entities;

        public EntitiesContext Entities => entities;

        public void Init()
        {
            entities = new EntitiesContext();
        }

        public void Save(bool isAsync = false)
        {
            if (isAsync)
            {
                entities.SaveChangesAsync();
            }
            else
            {
                entities.SaveChanges();
            }
        }
    }
}
